package com.zyh.homework.yichangzuoye.test3;

import java.util.Scanner;

public class Test {
    public static final Scanner INPUT = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("请输入一个整数：");
        while (true) {
            int n = INPUT.nextInt();
            if (n < 0) {
                try {
                    throw new Test3();
                } catch (Test3 e) {
                    System.out.println("N必须是正数或者0");
                    System.out.println("请再次输入一个整数：");
                }
            } else if (n >= 0) {
                System.out.println("输入的数字正确");
                break;
            }
        }
    }
}

class Test3 extends RuntimeException {
    public Test3() {
    }

    public Test3(String message) {
        super(message);
    }
}
